<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" isELIgnored="false" %>

<div class="form-horizontal row">
    <form id="form_result">
        <div class="col-sm-12" id="div_error"></div>
        <div class="form-group col-sm-5">
            <label class="col-sm-4 control-label">单位名称：</label>
            <div class="col-sm-8">
                <p class="form-control-static">${business.companyName}</p>
            </div>
        </div>

        <div class="form-group col-sm-5">
            <label class="col-sm-4 control-label">事　　项：</label>
            <div class="col-sm-8">
                <p class="form-control-static">${business.itemName}</p>
            </div>
        </div>
        <div class="form-group col-sm-5">
            <label class="col-sm-4 control-label">业务类型：</label>
            <div class="col-sm-8">
                <p class="form-control-static">${business.businessType}</p>
            </div>
        </div>


        <div class="form-group  col-sm-12">
            <div class="col-sm-9 col-sm-offset-1">
                <table id="table_result"></table>
            </div>
        </div>


        <div class="form-group col-sm-12">
            <div class="col-sm-1 col-sm-offset-9">
                <button type="button" id="btn_result" class="btn btn-default  btn-success ">
                    <span class="glyphicon glyphicon-ok"></span>&nbsp;提&nbsp;交&nbsp;
                </button>
            </div>
        </div>
    </form>

</div>
<script>
    $(function () {

        $btn_result.click(function () {
//            $btn_result.attr("disabled",true);

            var data = $table_result.bootstrapTable('getOptions').data;
            var crowIdCardList = [], leaderIdCard;
            for (var i = 0; i < data.length; i++) {
                if (data[i].leader == true) {
                    leaderIdCard = data[i].idCard;
                } else {
                    crowIdCardList.push(data[i].idCard);
                }
            }
            if (!leaderIdCard) {
                alert("请选择一位组长");
//                $btn_result.attr("disabled",false);
                return;
            } else {

                $.sysPlugin.superAjax({
                    data: {
                        crewIdCardList: crowIdCardList.toString(),
                        leaderIdCard: leaderIdCard,
                        checkPlanId: '${checkPlanId}'
                    },
                    url: "${base}/httpPage/andExpertToWeiChuang",
                    operateType: 'insert',
                    showSuccessAlert: true,
                    showWarnAlert: true,
                    successCall: function (data) {
                        closewin();
                    },
                    errorCall: function (data) {
//                        $btn_result.attr("disabled",false);
                        $.sysPlugin.errorCallBack(data, {
                            errorAddress: $("#div_error")
                        })
                    }
                });
            }
        });


        $table_result.bootstrapTable({
            striped: true,
            uniqueId: "idCard",                     //每一行的唯一标识，一般为主键列
            <c:if test="${oldData!=null}">
            data:${oldData},
            </c:if>
            columns: [
                {
                    formatter: function (value, row, index) {
                     return index+1;
                    }
                },
                {
                    field: 'leader',
                    radio: "true",
                    formatter: function (value, row, index) {
                        $(".bs-checkbox .th-inner").html("组长");
                    }
                },
                {
                    title: '姓名',
                    field: 'name',
                    events: 'events',
                    formatter: function (value, row, index) {
                        return [
                            '<div class="nameClick" ><a href="javascript:;" style="text-decoration: none ;display: block;width: 60px">' + value + '</a></div>'
                        ].join('');
                    }

                },
                {
                    field: 'idCard',
                    title: '身份证号码'
                },
                {
                    field: 'grade',
                    title: '专家类型'
                },
                {
                    field: 'affiliateCompany',
                    title: '所属单位'
                },
                {
                    field: 'phone',
                    title: '手机号码'
                },
                {
                    title: '操作',
                    events: 'events',
                    formatter: function (value, row, index) {
                        return [
                            '<button   type="button" class="btn btn-xs btn-default  unCheckExpert">' +
                            '<span class="glyphicon glyphicon-remove"></span> 取消' +
                            '</button>'
                        ].join('');
                    }
                }
            ]
        });

    });


    function closewin() {
        if (navigator.userAgent.indexOf("Firefox") != -1 || navigator.userAgent.indexOf("Chrome") != -1) {
            window.location.href = "about:blank";
            window.close();
        } else {
            window.opener = null;
            window.open("", "_self");
            window.close();
        }
    }


</script>